﻿using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using SharpAnalyzer.Utilities;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;

namespace SharpAnalyzer.Analyzers
{
    internal sealed class MethodParameterAnalyzer : CSharpSyntaxWalker
    {
        private int numParameters;

        public MethodParameterAnalyzer()
          : base(SyntaxWalkerDepth.Node)
        {
        }

        public int Calculate(SyntaxNode memberNode)
        {
            Verify.NotNull(() => memberNode);

            if (memberNode != null)
                Visit(memberNode);
            return numParameters;
        }

        public override void VisitParameter(ParameterSyntax node)
        {
            base.VisitParameter(node);
            checked { ++numParameters; }
        }
    }
}
